package com.weitu.hiddenDanger.service.impl;

import com.weitu.hiddenDanger.entity.HiddenDangerInfo;
import com.weitu.hiddenDanger.entity.Precaution;
import com.weitu.hiddenDanger.mapper.HDRegisterMapper;
import com.weitu.hiddenDanger.service.HDRegisterService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;
import java.util.Map;

/**
 * Created by fanyuting on 2017/3/31 0031.
 * 隐患登记Service实现类
 */
@Service
public class HDRegisterServiceImpl implements HDRegisterService {
    @Autowired
    private HDRegisterMapper hdRegisterMapper;



    /**
     *添加隐患登记信息
     * @param map
     * @return
     */
    @Transactional
    public boolean addHDRegisterInfo(Map<String,Object> map){
        int flag =this.hdRegisterMapper.addHDRegisterInfo(map);
        if(flag<1){
            return false;
        }
        return true;
    }
    /**
     * 编辑隐患登记信息
     * @param map
     * @return
     */
    @Transactional
    public boolean editHDRegisterInfo(Map<String,Object> map){
        int flag = this.hdRegisterMapper.editHDRegisterInfo(map);
        if(flag<1){
            return false;
        }
        return true;
    }
    /**
     * 删除隐患登记信息
     * @param map
     * @return
     */
    @Transactional
    public boolean deleteHDRegisterInfo(Map<String,Object> map){
        int flag = this.hdRegisterMapper.deleteHDRegisterInfo(map);
        if(flag<1){
            return false;
        }
        return true;
    }
    /**
     * 根据id查询隐患信息
     * @param map
     * @return
     */
    public List<HiddenDangerInfo> queryHDRegisterInfoById(Map<String,Object> map){
        return this.hdRegisterMapper.queryHDRegisterInfoById(map);
    }
    /**
     * 查询隐患分页列表数据
     * @param map
     * @return
     */
    @Override
    public List<HiddenDangerInfo> queryList(Map<String, Object> map) {

        return this.hdRegisterMapper.queryList(map);
    }

    /**
     * 查询分页列表总数
     * @param map
     * @return
     */
    @Override
    public int queryListCount(Map<String, Object> map) {
        return this.hdRegisterMapper.queryListCount(map);
    }

    /**
     * 更改审批状态
     * @param id
     * @return
     */
    public boolean editHDRegisterAppState( String id,String appState){
        int flag = this.hdRegisterMapper.editHDRegisterAppState(id,appState);
        if(flag<1){
            return false;
        }
        return true;
    }


}
